package com.zhou.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhou.api.dto.InventoryDTO;
import com.zhou.api.entity.Inventory;
import com.zhou.result.R;
import com.zhou.service.InventoryService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description : 出入库详情
 * @Author : zyy
 * @Date: 2024/8/22  15:08
 */
@RestController
@RequestMapping("inventory")
@Api(tags = "出入库详情")
public class InventoryController {
    @Resource
    private InventoryService inventoryService;

    /**
     * 添加入库
     * @param dto
     */
    @PostMapping("add")
    @Operation(summary = "添加入库")
    public void add (@RequestBody InventoryDTO dto) {
        inventoryService.add(dto);
    }

    /**
     * 修改出库
     * @param id
     */
    @PostMapping("update")
    @Operation(summary = "修改出库")
    public void update (@PathVariable("id") String id) {
        inventoryService.update(id);
    }

    /**
     * 删除记录
     * @param id
     */
    @PostMapping("delete")
    @Operation(summary = "删除记录")
    public void delete (@PathVariable("id") String id) {
        inventoryService.delete(id);
    }

    /**
     * 获取列表
     * @param page 分页条件
     * @param delFlag 删除标识
     * @param inventoryStatus 出入库状态
     * @param status 状态
     * @return
     */
    @GetMapping("getList")
    @Operation(summary = "获取列表")
    public R<Page<Inventory>> getList (Page page,@RequestParam(required = false) String delFlag,@RequestParam(required = false) String inventoryStatus,
                                       @RequestParam(required = false) String status) {
        return R.success(inventoryService.getList(page,delFlag,inventoryStatus,status));
    }
}
